---
title: "verify_key"
description: "Verify a key"
---

> @spec verify_key(binary, map()) :: map()

Verify a key from your users. You only need to send the api key from your user.
Optionally, pass in a second param, a map with the key `apiId` which sends the `apiId` along.

## Request

<ParamField body="key" type="string" required>
  The key you want to verify.
</ParamField>

<ParamField body="apiId" type="string" required>
  The `API` of the key you want to verify.
</ParamField>

## Response

<ResponseField name="valid" type="boolean" required>
  Whether or not this key is valid and has passed the ratelimit. If `false` you
  should not grant access to whatever the user is requesting
</ResponseField>
<ResponseField name="ownerId" type="string">
  If you have set an `ownerId` on this key it is returned here. You can use this
  to clearly authenticate a user in your system.
</ResponseField>

<ResponseField name="meta" type="object" >
This is the `meta` data you have set when creating the key.

Example:

```json
{
  "billingTier": "PRO",
  "trialEnds": "2023-06-16T17:16:37.161Z"
}
```

</ResponseField>

<RequestExample>

```elixir
   try do
     is_verified = UnkeyElixirSdk.verify_key("xyz_AS5HDkXXPot2MMoPHD8jnL", %{
      "apiId" => "api_7oKUUscTZy22jmVf9THxDA"
     })

    catch
        err ->
          Logger.error(err)
      end
```

</RequestExample>

<ResponseExample>
```ts
{
	valid: true,
	ownerId: "glamboyosa",
	meta: {
		hello: "world"
	}
}
```

</ResponseExample>
